package com.harisucici.websocketlib.utils;

import com.google.gson.Gson;
import com.harisucici.websocketlib.modle.BaseSendEntity;

public class BaseEntityBuild extends Builder {

    BaseSendEntity baseEntity = new BaseSendEntity();

    @Override
    public void setType(String type) {
        baseEntity.setCmdType(type);
    }

    @Override
    public void setFromAccount(String account) {
        BaseSendEntity.FromAccountEntity fromAccountEntity = new BaseSendEntity.FromAccountEntity();
        fromAccountEntity.setAccountId(account);
        baseEntity.setFromAccount(fromAccountEntity);
    }

    @Override
    public void setToAccount(String account) {
        BaseSendEntity.ToAccountEntity toAccountEntity = new BaseSendEntity.ToAccountEntity();
        toAccountEntity.setAccountId(account);
        baseEntity.setToAccount(toAccountEntity);
    }

    @Override
    public void setPayLoad(Object payLoad) {
        baseEntity.setPayLoad(payLoad);

    }

    @Override
    public String createContent() {
        return new Gson().toJson(baseEntity);
    }

    @Override
    public BaseSendEntity createEntity() {
        return baseEntity;
    }
}
